fix: gate feature-injection kwargs on TensorRT backend in SD1.5/2.1 UNet call#13
Merged
Merged
Conversation
…Net call (#12) The SD1.5/2.1 branch of unet_step() unconditionally passed kvo_cache/fio_cache/ fi_strength/fi_threshold to self.unet(...). The import-time diffusers patch (_patches/diffusers_kvo_patch.py) adds kvo_cache support to the eager PyTorch UNet, but feature injection is TensorRT-engine-only — the patched forward() has no fio_cache/fi_strength/fi_threshold parameters. Every non-TRT SD1.5/2.1 run (e.g. acceleration: none) crashed on the first call: UNet2DConditionModel.forward() got an unexpected keyword argument 'fio_cache' Mirrors the SDXL branch's existing _check_unet_tensorrt() gate: kvo_cache is always passed (both backends support it), the FI trio only when TRT is active. Adds tests/unit/test_unet_call_backend_gate.py, which reproduces the crash via a real (patched) tiny UNet2DConditionModel at the actual unet_step() call site and locks in that the TensorRT path keeps receiving all four cache kwargs.
|
Claude finished @forkni's task in 1m 37s —— View job Code review
No issues found. Checked for bugs and CLAUDE.md compliance (no CLAUDE.md exists in this repo). Summary: This is a clean, verbatim cherry-pick of the already-reviewed/tested fix from #12.
No bugs, logic errors, or CLAUDE.md violations found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cherry-pick of the same fix landed on
SDTD_040_beta_releasein #12 (files were byte-identical pre-fix, so this is a clean, verbatim port).acceleration: none/xformers/sfast):UNet2DConditionModel.forward() got an unexpected keyword argument 'fio_cache'.unet_step()'s SD1.5/2.1 branch unconditionally passedfio_cache/fi_strength/fi_thresholdtoself.unet(...), but those TensorRT-only feature-injection kwargs are not understood by the patched eager PyTorch UNet (_patches/diffusers_kvo_patch.pyonly addskvo_cache). The SDXL branch already gated these correctly on_check_unet_tensorrt(); the SD1.5/2.1 branch did not.kvo_cache(supported on both backends via the import-time patch), but gatefio_cache/fi_strength/fi_thresholdbehindself._check_unet_tensorrt(), matching the SDXL branch's convention.Test plan
tests/unit/test_unet_call_backend_gate.py, already verified green (3/3) plus a full 216/216 unit-suite pass against the identicalpipeline.pyon the 040 branch (fix: gate feature-injection kwargs on TensorRT backend in SD1.5/2.1 UNet call #12).🤖 Generated with Claude Code